/*
 * DemoMultiState.h
 *
 *  Created on: 2011-11-20
 *      Author: baixp
 */

#ifndef DEMOMULTISTATE_H_
#define DEMOMULTISTATE_H_
#include "Lib9.h"
#include "L9ResStr.h"
using namespace lib9bada;
class DemoMultiState: public Lib9, public L9IState {
public:
	DemoMultiState(Application* pApp);
	virtual ~DemoMultiState();

    //文字资源常量，由Lib9Editor编辑器在导出文本资源的时候自动生成
    static const int K_TEXT_NAME = 0;
    static const int K_TEXT_SCORE = 1;
    static const int K_TEXT_COLOR = 2;

    vector<String> strLines;

	void Init() {
		// TODO Auto-generated method stub
        //创建字符串资源对象，使用utf-8编码
		L9ResStr l9StrRes("/res/text");
        //获取相应的文字资源，XXXX为资源中需要被替换的字符串，“2,87”是要替换的字符串
        String name = l9StrRes.getResStr(K_TEXT_NAME);
        String score = l9StrRes.getResStr(K_TEXT_SCORE, "XXXX", "2,87", ",");
        String color = l9StrRes.getResStr(K_TEXT_COLOR);

        //\n将使得绘制字符串时强制换行，l9Str还支持在资源字符串中使用0xFF0000的方式来设置某一部分字符串的颜色值
        String str = name + "\n" + score + "\n" + color;
        //设置字符串的分页信息
        pL9Str->setPageSize(str, SCR_W - 8, SCR_H, 1);
	}

	void Update() {
		// TODO Auto-generated method stub
        if (isKeyPressed(K_KEY_5)) {
            quitApp();
        }
	}

	void Paint() {
		// TODO Auto-generated method stub
        fillScreen(0xFFFFFFFF);
        pFG->SetForegroundColor(Color(0xFF000000));
        pL9Str->drawPage(pFG,0, 4, 50, L9Str::K_Line_Align_Center);
	}
};

#endif /* DEMOMULTISTATE_H_ */
